-
Notifications
You must be signed in to change notification settings - Fork 14k
feat: dlopen Enzyme #149271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: dlopen Enzyme #149271
Conversation
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred in compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs cc @ZuseZ4 |
|
That's exciting, and is gonna make some people on the infra team very happy. Just to be sure, are the tests still passing? |
This comment has been minimized.
This comment has been minimized.
| let attr_name = "enzyme_type"; | ||
| let c_attr_name = CString::new(attr_name).unwrap(); | ||
|
|
||
| let enzyme_wrapper = EnzymeWrapper::get_instance().lock().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe return a MutexGuard from EnzymeWrapper::get_instance()?
| fn enable_autodiff_settings(ad: &[config::AutoDiff]) { | ||
| fn enable_autodiff_settings(cgcx: &CodegenContext<LlvmCodegenBackend>, ad: &[config::AutoDiff]) { | ||
| use std::sync::Mutex; | ||
| let enzyme: &'static Mutex<llvm::EnzymeWrapper> = llvm::EnzymeWrapper::init(cgcx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe return a MutexGuard from EnzymeWrapper::init()?
| } | ||
|
|
||
| fn enable_autodiff_settings(ad: &[config::AutoDiff]) { | ||
| fn enable_autodiff_settings(cgcx: &CodegenContext<LlvmCodegenBackend>, ad: &[config::AutoDiff]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call this from LlvmCodegenBackend::init() instead? There you have access to the full Session.
|
(oops, sorry I should have run tests before opening this pr. It takes too much time running tests on my m1 mac so let me check them tomorrow, including ci failures..... 🙇) |
|
Don't worry. I don't run all tests either before opening a PR either, that indeed takes way too long. I mostly run |
|
Oh sorry, I was only referring to all the autodiff tests mentioned here. I'm also not running all tests. |
This comment has been minimized.
This comment has been minimized.
|
@sgasho It seems that all autodiff tests invoking enzyme fail, e.g: thread 'rustc' (2936300) panicked at compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs:211:35:
EnzymeWrapper not initialized
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::option::expect_failed
3: rustc_codegen_llvm::typetree::add_tt
4: rustc_codegen_llvm::intrinsic::codegen_autodiffI still remember I had the same issue in my original PR, so that might be the reason. |
…or_init takes only sysroot, not a whole session or context
|
Some changes occurred in compiler/rustc_codegen_llvm/src/builder/autodiff.rs cc @ZuseZ4 |
I solved the "EnzymeWrapper not initialized" problem in the latest commit (52f0d2e) However, another error occurred e.g. ./x test --stage 1 tests/codegen-llvm/autodiff/scalar.rs
Building bootstrap
Finished `dev` profile [unoptimized] target(s) in 0.14s
WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.
NOTE: to silence this warning, add `change-id = 148803` or `change-id = "ignore"` at the top of `bootstrap.toml`
Building stage1 compiler artifacts (stage0 -> stage1, aarch64-apple-darwin)
Finished `release` profile [optimized] target(s) in 0.55s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 wasm-component-ld (stage0 -> stage1, aarch64-apple-darwin)
Finished `release` profile [optimized] target(s) in 0.59s
Building stage1 llvm-bitcode-linker (stage0 -> stage1, aarch64-apple-darwin)
Finished `release` profile [optimized] target(s) in 0.12s
Building stage1 library artifacts (stage1 -> stage1, aarch64-apple-darwin)
Finished `release` profile [optimized] target(s) in 0.25s
Building stage1 compiletest (stage0 -> stage1, aarch64-apple-darwin)
Finished `release` profile [optimized] target(s) in 2.77s
Testing stage1 with compiletest suite=codegen-llvm mode=codegen (aarch64-apple-darwin)
running 1 tests
[codegen] tests/codegen-llvm/autodiff/scalar.rs ... F
failures:
---- [codegen] tests/codegen-llvm/autodiff/scalar.rs stdout ----
------rustc stdout------------------------------
------rustc stderr------------------------------
Assertion failed: (AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"), function getResult, file PassManager.h, line 414.
------------------------------------------
error: compilation failed!
status: signal: 6 (SIGABRT)
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/build/aarch64-apple-darwin/stage1/bin/rustc" "/Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/tests/codegen-llvm/autodiff/scalar.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Users/suganoshota/.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/vendor" "--sysroot" "/Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/build/aarch64-apple-darwin/stage1" "--target=aarch64-apple-darwin" "--check-cfg" "cfg(test,FALSE)" "-O" "-Cdebug-assertions=no" "-Zcodegen-source-order" "--emit" "llvm-ir" "-o" "/Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/build/aarch64-apple-darwin/test/codegen-llvm/autodiff/scalar/scalar.ll" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Zautodiff=Enable,NoTT" "-C" "opt-level=3" "-Clto=fat"
stdout: none
--- stderr -------------------------------
Assertion failed: (AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"), function getResult, file PassManager.h, line 414.
------------------------------------------
---- [codegen] tests/codegen-llvm/autodiff/scalar.rs stdout end ----
failures:
[codegen] tests/codegen-llvm/autodiff/scalar.rs
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 964 filtered out; finished in 529.35ms
Some tests failed in compiletest suite=codegen-llvm mode=codegen host=aarch64-apple-darwin target=aarch64-apple-darwin
Build completed unsuccessfully in 0:00:18I could not figure out what triggers "This analysis pass was not registered prior to being queried". codex cli says Enzyme has a problem but I'm not sure if it's right. I'll take look into it tomorrow.
|
|
The job Click to see the possible cause of the failure (guessed by this bot) |
1 similar comment
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
Do you have a backtrace? |
|
I saw no further information using RUST_BACKTRACE=1 RUST_BACKTRACE=1 ./x test --stage 1 tests/codegen-llvm/autodiff/scalar.rsor set RUST_BACKTRACE=1
./x test --stage 1 tests/codegen-llvm/autodiff/scalar.rs |
|
You will have to use a debugger. These are LLVM aborts, not rust panics, so |
|
I see! Launching: /Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/build/aarch64-apple-darwin/stage1/bin/rustc /Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/tests/codegen-llvm/autodiff/scalar.rs -Zthreads=1 -Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Ztranslate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/Users/suganoshota/.cargo -Z ignore-directory-in-diagnostics-source-blocks=/Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/vendor --sysroot /Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/build/aarch64-apple-darwin/stage1 --target aarch64-apple-darwin --check-cfg cfg(test,FALSE) -O -Cdebug-assertions=no -Zcodegen-source-order --emit llvm-ir -o /Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/build/aarch64-apple-darwin/test/codegen-llvm/autodiff/scalar/scalar.ll -A internal_features -A unused_parens -A unused_braces -Crpath -Cdebuginfo=0 -Zautodiff=Enable,NoTT -C opt-level=3 -Clto=fat
Launched process 22915 from '/Volumes/WD_BLACK_SN850X_HS_1TB/rust-lang/rust/build/aarch64-apple-darwin/stage1/bin/rustc'
Assertion failed: (AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"), function getResult, file PassManager.h, line 414.
Stop reason: hit program assert
thread backtrace all
thread #1, name = 'main', queue = 'com.apple.main-thread'
frame #0: 0x0000000186068ae4 libsystem_kernel.dylib`__ulock_wait + 8
frame #1: 0x00000001860ac0ac libsystem_pthread.dylib`_pthread_join + 608
frame #2: 0x0000000109051888 librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::join at unix.rs:134:28 [opt]
frame #3: 0x00000001063005c0 librustc_driver-1894da91bc51a45d.dylib`<std::thread::JoinInner<()>>::join + 32
frame #4: 0x000000010630449c librustc_driver-1894da91bc51a45d.dylib`rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}> + 2292
frame #5: 0x00000001062aa518 librustc_driver-1894da91bc51a45d.dylib`rustc_driver_impl::run_compiler + 4248
frame #6: 0x00000001062b074c librustc_driver-1894da91bc51a45d.dylib`rustc_driver_impl::main + 208
frame #7: 0x00000001000007b0 rustc`rustc_main::main + 12
frame #8: 0x0000000100000764 rustc`std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()> + 12
frame #9: 0x000000010000077c rustc`std::rt::lang_start::<()>::{closure#0} + 16
frame #10: 0x0000000109046f94 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once at function.rs:287:21 [opt]
frame #11: 0x0000000109046f8c librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind::do_call at panicking.rs:590:40 [opt]
frame #12: 0x0000000109046f88 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind at panicking.rs:553:19 [opt]
frame #13: 0x0000000109046f88 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] std::panic::catch_unwind at panic.rs:359:14 [opt]
frame #14: 0x0000000109046f88 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] std::rt::lang_start_internal::{{closure}} at rt.rs:175:24 [opt]
frame #15: 0x0000000109046bb8 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind::do_call at panicking.rs:590:40 [opt]
frame #16: 0x0000000109046bb8 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind at panicking.rs:553:19 [opt]
frame #17: 0x0000000109046bb8 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal [inlined] std::panic::catch_unwind at panic.rs:359:14 [opt]
frame #18: 0x0000000109046bb8 librustc_driver-1894da91bc51a45d.dylib`std::rt::lang_start_internal at rt.rs:171:5 [opt]
frame #19: 0x00000001000007e4 rustc`main + 52
frame #20: 0x0000000185ce1d54 dyld`start + 7184
thread #2, name = 'ctrl-c'
frame #0: 0x0000000186067908 libsystem_kernel.dylib`read + 8
frame #1: 0x00000001062eac68 librustc_driver-1894da91bc51a45d.dylib`std::sys::backtrace::__rust_begin_short_backtrace::<ctrlc::set_handler_inner<rustc_driver_impl::install_ctrlc_handler::{closure#0}>::{closure#0}, ()> + 52
frame #2: 0x00000001062feeec librustc_driver-1894da91bc51a45d.dylib`<<std::thread::Builder>::spawn_unchecked_<ctrlc::set_handler_inner<rustc_driver_impl::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 108
frame #3: 0x0000000109051578 librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start [inlined] <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at boxed.rs:2005:9 [opt]
frame #4: 0x000000010905156c librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start at unix.rs:126:17 [opt]
frame #5: 0x00000001860a9c08 libsystem_pthread.dylib`_pthread_start + 136
thread #3, name = 'rustc'
frame #0: 0x0000000186066bb0 libsystem_kernel.dylib`semaphore_wait_trap + 8
frame #1: 0x0000000185eee990 libdispatch.dylib`_dispatch_sema4_wait + 28
frame #2: 0x0000000185eeef40 libdispatch.dylib`_dispatch_semaphore_wait_slow + 132
frame #3: 0x0000000109058d20 librustc_driver-1894da91bc51a45d.dylib`std::thread::Thread::park [inlined] std::sys::sync::thread_parking::darwin::Parker::park at darwin.rs:74:15 [opt]
frame #4: 0x0000000109058d00 librustc_driver-1894da91bc51a45d.dylib`std::thread::Thread::park at mod.rs:1498:47 [opt]
frame #5: 0x0000000107fc6308 librustc_driver-1894da91bc51a45d.dylib`<std::sync::mpmc::list::Channel<rustc_codegen_ssa::back::write::SharedEmitterMessage>>::recv::{closure#1} + 324
frame #6: 0x0000000107fc6d10 librustc_driver-1894da91bc51a45d.dylib`<std::sync::mpmc::list::Channel<rustc_codegen_ssa::back::write::SharedEmitterMessage>>::recv + 372
frame #7: 0x0000000107fa550c librustc_driver-1894da91bc51a45d.dylib`<rustc_codegen_ssa::back::write::SharedEmitterMain>::check + 152
frame #8: 0x00000001065e5e98 librustc_driver-1894da91bc51a45d.dylib`<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::join_codegen + 168
frame #9: 0x00000001064fc31c librustc_driver-1894da91bc51a45d.dylib`<rustc_interface::queries::Linker>::link + 304
frame #10: 0x000000010630dd6c librustc_driver-1894da91bc51a45d.dylib`rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1} + 3524
frame #11: 0x000000010630192c librustc_driver-1894da91bc51a45d.dylib`rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}> + 328
frame #12: 0x00000001062eae1c librustc_driver-1894da91bc51a45d.dylib`std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> + 104
frame #13: 0x00000001062ff1bc librustc_driver-1894da91bc51a45d.dylib`<<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 268
frame #14: 0x0000000109051578 librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start [inlined] <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at boxed.rs:2005:9 [opt]
frame #15: 0x000000010905156c librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start at unix.rs:126:17 [opt]
frame #16: 0x00000001860a9c08 libsystem_pthread.dylib`_pthread_start + 136
thread #4
frame #0: 0x000000018606a4f8 libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001860aa0dc libsystem_pthread.dylib`_pthread_cond_wait + 984
frame #2: 0x000000010902d680 librustc_driver-1894da91bc51a45d.dylib`<jobserver::HelperState>::for_each_request::<jobserver::imp::spawn_helper::{closure#1}::{closure#0}> + 256
frame #3: 0x0000000109030620 librustc_driver-1894da91bc51a45d.dylib`std::sys::backtrace::__rust_begin_short_backtrace::<jobserver::imp::spawn_helper::{closure#1}, ()> + 36
frame #4: 0x000000010902f91c librustc_driver-1894da91bc51a45d.dylib`<<std::thread::Builder>::spawn_unchecked_<jobserver::imp::spawn_helper::{closure#1}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 160
frame #5: 0x0000000109051578 librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start [inlined] <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at boxed.rs:2005:9 [opt]
frame #6: 0x000000010905156c librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start at unix.rs:126:17 [opt]
frame #7: 0x00000001860a9c08 libsystem_pthread.dylib`_pthread_start + 136
thread #5
frame #0: 0x000000018606a4f8 libsystem_kernel.dylib`__psynch_cvwait + 8
frame #1: 0x00000001860aa0dc libsystem_pthread.dylib`_pthread_cond_wait + 984
frame #2: 0x000000010902d680 librustc_driver-1894da91bc51a45d.dylib`<jobserver::HelperState>::for_each_request::<jobserver::imp::spawn_helper::{closure#1}::{closure#0}> + 256
frame #3: 0x0000000109030620 librustc_driver-1894da91bc51a45d.dylib`std::sys::backtrace::__rust_begin_short_backtrace::<jobserver::imp::spawn_helper::{closure#1}, ()> + 36
frame #4: 0x000000010902f91c librustc_driver-1894da91bc51a45d.dylib`<<std::thread::Builder>::spawn_unchecked_<jobserver::imp::spawn_helper::{closure#1}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 160
frame #5: 0x0000000109051578 librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start [inlined] <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at boxed.rs:2005:9 [opt]
frame #6: 0x000000010905156c librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start at unix.rs:126:17 [opt]
frame #7: 0x00000001860a9c08 libsystem_pthread.dylib`_pthread_start + 136
thread #6, name = 'coordinator'
frame #0: 0x0000000186066bb0 libsystem_kernel.dylib`semaphore_wait_trap + 8
frame #1: 0x0000000185eee990 libdispatch.dylib`_dispatch_sema4_wait + 28
frame #2: 0x0000000185eeef40 libdispatch.dylib`_dispatch_semaphore_wait_slow + 132
frame #3: 0x0000000109058d20 librustc_driver-1894da91bc51a45d.dylib`std::thread::Thread::park [inlined] std::sys::sync::thread_parking::darwin::Parker::park at darwin.rs:74:15 [opt]
frame #4: 0x0000000109058d00 librustc_driver-1894da91bc51a45d.dylib`std::thread::Thread::park at mod.rs:1498:47 [opt]
frame #5: 0x000000010666a278 librustc_driver-1894da91bc51a45d.dylib`<std::sync::mpmc::list::Channel<rustc_codegen_ssa::back::write::Message<rustc_codegen_llvm::LlvmCodegenBackend>>>::recv::{closure#1} + 140
frame #6: 0x000000010666b398 librustc_driver-1894da91bc51a45d.dylib`<std::sync::mpmc::list::Channel<rustc_codegen_ssa::back::write::Message<rustc_codegen_llvm::LlvmCodegenBackend>>>::recv + 460
frame #7: 0x00000001065d921c librustc_driver-1894da91bc51a45d.dylib`rustc_codegen_ssa::back::write::start_executing_work::<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#4} + 1528
frame #8: 0x00000001065d868c librustc_driver-1894da91bc51a45d.dylib`std::sys::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::start_executing_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#4}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>>::{closure#0}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>> + 72
frame #9: 0x00000001065df85c librustc_driver-1894da91bc51a45d.dylib`<<std::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::start_executing_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#4}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>>::{closure#0}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 472
frame #10: 0x0000000109051578 librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start [inlined] <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at boxed.rs:2005:9 [opt]
frame #11: 0x000000010905156c librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start at unix.rs:126:17 [opt]
frame #12: 0x00000001860a9c08 libsystem_pthread.dylib`_pthread_start + 136
* thread #7, name = 'opt cgu.0', stop reason = hit program assert
* frame #0: 0x000000018606f5b0 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x00000001860a9888 libsystem_pthread.dylib`pthread_kill + 296
frame #2: 0x0000000185fae850 libsystem_c.dylib`abort + 124
frame #3: 0x0000000185fada84 libsystem_c.dylib`__assert_rtn + 284
frame #4: 0x00000001057ed734 libEnzyme-21.dylib`TypeAnalyzer::TypeAnalyzer(FnTypeInfo const&, TypeAnalysis&, unsigned char) + 3960
frame #5: 0x00000001058267fc libEnzyme-21.dylib`TypeAnalysis::analyzeFunction(FnTypeInfo const&) + 288
frame #6: 0x000000010568fa5c libEnzyme-21.dylib`(anonymous namespace)::EnzymeBase::HandleAutoDiff(llvm::Instruction*, unsigned int, llvm::Value*, llvm::Type*, llvm::SmallVectorImpl<llvm::Value*>&, std::__1::map<int, llvm::Type*, std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, llvm::Type*>>> const&, std::__1::vector<DIFFE_TYPE, std::__1::allocator<DIFFE_TYPE>> const&, llvm::Function*, DerivativeMode, (anonymous namespace)::EnzymeBase::Options&, bool, llvm::SmallVectorImpl<llvm::CallInst*>&) + 1580
frame #7: 0x000000010568a0a0 libEnzyme-21.dylib`(anonymous namespace)::EnzymeBase::HandleAutoDiffArguments(llvm::CallInst*, DerivativeMode, bool, llvm::SmallVectorImpl<llvm::CallInst*>&) + 644
frame #8: 0x00000001056856d8 libEnzyme-21.dylib`(anonymous namespace)::EnzymeBase::lowerEnzymeCalls(llvm::Function&, std::__1::set<llvm::Function*, std::__1::less<llvm::Function*>, std::__1::allocator<llvm::Function*>>&) + 13188
frame #9: 0x0000000105680974 libEnzyme-21.dylib`(anonymous namespace)::EnzymeBase::run(llvm::Module&) + 1384
frame #10: 0x000000010569e6bc libEnzyme-21.dylib`llvm::detail::PassModel<llvm::Module, EnzymeNewPM, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 28
frame #11: 0x000000011816727c libLLVM.dylib`llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 328
frame #12: 0x00000001066f9888 librustc_driver-1894da91bc51a45d.dylib`LLVMRustOptimize + 10124
frame #13: 0x000000010667a720 librustc_driver-1894da91bc51a45d.dylib`rustc_codegen_llvm::back::write::llvm_optimize + 3500
frame #14: 0x000000010667e1d0 librustc_driver-1894da91bc51a45d.dylib`rustc_codegen_llvm::back::write::optimize + 508
frame #15: 0x00000001065d7060 librustc_driver-1894da91bc51a45d.dylib`rustc_codegen_ssa::back::write::execute_optimize_work_item::<rustc_codegen_llvm::LlvmCodegenBackend> + 140
frame #16: 0x00000001065d7e8c librustc_driver-1894da91bc51a45d.dylib`std::sys::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::spawn_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#0}, ()>::{closure#0}, ()> + 180
frame #17: 0x00000001065df1a8 librustc_driver-1894da91bc51a45d.dylib`<<std::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::spawn_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#0}, ()>::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} + 212
frame #18: 0x0000000109051578 librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start [inlined] <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at boxed.rs:2005:9 [opt]
frame #19: 0x000000010905156c librustc_driver-1894da91bc51a45d.dylib`std::sys::thread::unix::Thread::new::thread_start at unix.rs:126:17 [opt]
frame #20: 0x00000001860a9c08 libsystem_pthread.dylib`_pthread_start + 136 |
|
Good that you properly solved the first bug. I had just commented it out back in my PR and then ended up running into the same bug you're seeing now as well |
|
To be more clear at what did (not) work. In my first attempt where I just dlopen'ed Enzyme directly in |

related issue: #145899
related pr: #146623
This PR is a continuation of #146623
I refactored some code for #146623 and added the functions shown in #144197
r? @bjorn3
cc: @ZuseZ4
Zulip link: https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/libload.20.2F.20dlopen.20Enzyme.2Fautodiff/near/553647912